import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import VueDevTools from 'vite-plugin-vue-devtools'

// https://vitejs.dev/config/
export default defineConfig({

  server: {
    host: 'localhost',
    port: 8080, // 端口
    proxy: {
        '/api': { // 请求接口中要替换的标识
            target: 'http://127.0.0.1:8888', // 代理地址
            changeOrigin: true, // 是否允许跨域
            secure: true,
            rewrite: (path) => path.replace(/^\/api/, '/api') // api标志替换为''
        }
    }
  },
  plugins: [
    vue(),
    VueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
